﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CacheService.Standard;
using Common.Standard;
using Microsoft.AspNetCore.Mvc;
using WebApi.Filter;

namespace WebApi.Controllers
{
    [NoLogin]
    public class HomeController : Controller
    {
        
        private ICache cache;

        public HomeController(ICache _cache)
        {
            this.cache = _cache;
        }

        public IActionResult Index()
        {
            return Content(Request.HttpContext.Connection.RemoteIpAddress.ToString());
        }
        [HttpGet]
        public IActionResult GetCahce(string key)
        {
            return Content(cache.hasKey($"{key}:user") + ".....0_0");
        }
        public IActionResult GetImg()
        {
            var contentTypeStr = "image/jpeg";
          var bytes=ImageHelper.ImageToBytes(  ImageHelper.QrCode("http://www.baidu.com"));
            return new FileContentResult(bytes, contentTypeStr);
        }
    }
}